import { ModifyPassword, UserInfo } from "@/type/accountManage";
import axios, { Response } from "./axios";
import factorySingleClass from "./SingleClass";

class AccountManageService {
    verifyCode(phone: string) {
        return axios.post(
            `/usersys-auth/common/verify_code?phone=${phone}`,
            {},
        );
    }
    checkVerifyCode(query: string) {
        return axios.get<Response<any>>(
            `/usersys-auth/common/check_verify_code?${query}`,
        );
    }
    modify(query: string) {
        return axios.put<Response<boolean>>(
            `/usersys-auth/user/phone?${query}`,
        );
    }
    isSetPassword() {
        return axios.get<Response<boolean>>(
            `/usersys-app/trade/user/isSetPassword`,
        );
    }
    password(query: string) {
        return axios.put<Response<any>>(
            encodeURI(`/usersys-auth/user/password?${query}`),
        );
    }
    reset(query: string) {
        return axios.put<Response<any>>(
            `/usersys-auth/user/password/reset?${query}`,
        );
    }
    getEmailCode(code: string) {
        return axios.post(`/usersys-auth/user/email/code?email=${code}`, {});
    }
    email(query: string) {
        return axios.put<Response<any>>(`/usersys-auth/user/email?${query}`);
    }
    checkEmailCode(query: string) {
        return axios.post<Response<any>>(
            `/usersys-auth/user/email/code/check?${query}`,
        );
    }
    getUserInfo() {
        return axios.get<Response<UserInfo>>(`/usersys-auth/user/login_info`);
    }
}
export default factorySingleClass(AccountManageService);
